# 2024/4/17 上午11:46 HFL
import pytest
import requests

from Utils.RequestUtils import Request


class TestCourse:

    def setup_class(self):
        self.base_url = 'http://kdtx-test.itheima.net'
        self.uuid = requests.get(url=self.base_url + '/api/captchaImage').json()['uuid']
        login_json = {
            "username": "admin",
            "password": "HM_2023_test",
            "code": "2",
            "uuid": self.uuid
        }
        request = Request()
        url_login = self.base_url + '/api/login'
        self.token = request.post(url=url_login, json=login_json).json()['token']
    # @pytest.mark.repeat(100000)
    def test_add_course(self):
        url_add_course = self.base_url + '/api/clues/course'
        headers = {
            "Content-Type": "application/json",
            "Authorization": "Bearer" + " " + self.token
        }
        course_json = {
            "name": "小张的课程",
            "subject": 6,
            "price": 20,
            "applicablePerson": 2
        }
        request = Request()
        response = request.post(url=url_add_course, json=course_json, headers=headers)
        print(response.json())